/**
 * Created by Administrator on 2017/7/28.
 */
Ext.onReady(function () {
function XY_SHOW_USER(uid){
        this.uid=uid;
        this.window;
        this.grid;
        this.InitComponent();
}
XY_SHOW_USER.prototype={
    show:function(){
    this.window.show();
    }
}
XY_SHOW_USER.prototype.InitComponent=function(){
    var myData = [
        { name : "Asha", type : "16", id : 1 },
        { name : "Vinit", type : "18", id : 2 },
        { name : "Anand", type : "20", id : 3 },
        { name : "Niharika", type : "21", id : 4 },
        { name : "Manali", type : "22", id : 5 }
    ];
    var store = Ext.create('Ext.data.ArrayStore', {
        // store 的配置
        autoDestroy: true,
        storeId: 'myStore',
        extend: 'Ext.data.Model',
        // reader的配置
        idIndex: 0,
        fields: [
            'data',
            {name: 'id', mapping : 'id'},
            {name: 'name', mapping : 'name'},
            {name: 'type', mapping : 'type'},
        ]
        ,
        data:myData,
    });
    this.grid=new Ext.grid.GridPanel({
        xtype: 'grid',   //表格
        border: false,   //  边界
        columns: [
            {id:'id',header: "序号", width: 50, sortable: true,  dataIndex: 'id'},
            {header: "物理表名", width: 100, sortable: true, dataIndex: 'name'},
            {
                header: "类型",
                width: 75,
                sortable: true,
                dataIndex: 'type',
                renderer: function (value, metadata, record, rowIndex, colIndex, store) {
                    if (value > 16) {
                        return "1";
                    } else {
                        return "2";
                    }
                }
            },
        ],
        store: store // 一个假的空的数据存储
    });
    this.window = new Ext.Window({
        title: "添加用户信息",
        width: 530,
        height:380,
        plain: true,
        iconCls: "addicon",
        //不可以随意改变大小
        resizable: false,
        //是否可以拖动
        draggable: true,
        defaultType: "textfield",
        labelWidth: 100,
        labelAlign: "right",
        collapsible: true, //允许缩放条
        closeAction: 'close',
        closable: true,
        //弹出模态窗体
        modal: 'true',
        buttonAlign: "center",
        items: [this.grid],

        buttons: [{
            text: "保存",
            minWidth: 70,

        }
            , {
                text: "取消",
                minWidth: 70,

            }]
    });

}

    SHOW_USER=function(uid){
        var su=new XY_SHOW_USER(uid);
        su.show();
    }
    SHOW_USER(1);
});